package com.itboye.ihomebank.activity.finance.fragment;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ProgressBar;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseFragment;
import com.itboye.ihomebank.constants.NetPublicConstant;

/**
 * 基础详情
 */
@SuppressLint("ValidFragment")
public class TouZiXQFragment extends BaseFragment{
    WebView webview;
    ProgressBar myProgressBar;
    String id;

    public TouZiXQFragment(String id){
        this.id=id;
    }
    @Override
    public int initView() {
        return R.layout.fragment_tou_zi_xq;
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @Override
    public void onMyActivityCreated() {

       String urls= NetPublicConstant.WEB_URL02+ "/p2p/detail?id=" + id ;

        //支持javascript   表示不支持js，如果想让java和js交互或者本身希望js完成一定的功能请把false改为true。
        webview.getSettings().setJavaScriptEnabled(true);
        // 设置可以支持缩放
        webview.getSettings().setSupportZoom(true);
        // 设置出现缩放工具
        webview.getSettings().setBuiltInZoomControls(true);
        //不显示webview缩放按钮
        webview.getSettings().setDisplayZoomControls(false);
        //扩大比例的缩放(设置WebView支持viewpoart)
        webview.getSettings().setUseWideViewPort(true);
        //自适应屏幕(设置网页超过屏幕宽度时重新布局为屏幕宽度)
        webview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webview.getSettings().setLoadWithOverviewMode(true);
        webview.loadUrl(urls);

        webview.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                if (newProgress == 100) {
                    myProgressBar.setVisibility(View.GONE);
                } else {
                    if (View.GONE == myProgressBar.getVisibility()) {
                        myProgressBar.setVisibility(View.VISIBLE);
                    }
                    myProgressBar.setProgress(newProgress);
                }
                super.onProgressChanged(view, newProgress);
            }

        });
    }



}
